package collect.collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class TestSet {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        //添加元素
        System.out.println(set.add("徐瑞琪"));
        System.out.println(set.add("徐瑞琪"));
        System.out.println(set.add("张航"));
        System.out.println(set.add("朱鹏"));
        System.out.println(set.add("朱思衡"));
        //迭代器
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            System.out.println(s);
        }
        System.out.println("========================");
        //增强for
        for (String s : set) {
            System.out.println(s);
        }
        System.out.println("========================");
        //Lambda
        set.forEach(s -> System.out.println(s));
    }
}
